var MvcTemplates = function(){
    var public = {
                    
    };
    
    $(document).ready(function(){
        $(".autocomplete").each( function( index, element ) {
            var dataAttr = $(element).attr("data-autocomplete-data");            
            var urlAttr = $(element).attr("data-autocomplete-url");
            var formatItemAttr = $(element).attr("data-autocomplete-formatitem");
            var resultAttr = $(element).attr("data-autocomplete-result");

            var data;

            if ( dataAttr != undefined ){
                var values = dataAttr.split("||");
                data = [];
                $.each( values, function( i, e ) {
                    try{
                        data.push( eval(e) );
                    }
                    catch(err){
                        data.push( e );
                    }                    
                });
            } else {
                data = urlAttr;
            }

            var options = {};
            if ( formatItemAttr != undefined ){
                options = {
                    formatItem: function(item){
                        return eval(formatItemAttr);
                    }
                }
            }

            var autoComplete = $(element).autocomplete( data, options );

            if ( resultAttr != undefined ){
                autoComplete.result( function( event, data ) {
                    eval( resultAttr );
                });
            }

        } );
    });

    return public;
}();